
ac.card_class = {
    '通用',
    '斗破苍穹','异火',
    '葫芦娃','精怪',
    '蛊世界',
    '命运',
    '射手',
    '斗罗','史莱克七怪','武魂殿',
    '三国','魏','蜀','吴',
    '克苏鲁',
    '封神世界',
    '超级英雄',
    '七原罪',
    '七美德',
}

function hide_card(self,hide)
    local hero = self.owner
    local player = hero and hero.owner
    if player and self.is_hide_card==nil then
        local cards1 = hero:get_data('展示天赋表') or {}
        local cards2 = hero:get_data('吞噬天赋表') or {}
        local new_card = {}
        hero:set_data('吞噬天赋表',cards2)
        for a=1,12 do
            if cards1[a]==self then
                ac.game:notify('吞噬动画',player,self,a)
                cards1[a] = nil
            else
                table.insert(new_card,cards1[a])
            end
        end
        hero:set_data('展示天赋表',new_card)
        for a,skill in ipairs(cards2) do
            if skill.name==self.name and skill~=self then
                skill.card_count = (skill.card_count or 1) + 1
                self:remove()
                player:notify('玩家-刷新UI',player)
                return
            end
        end
        self.is_hide_card = true
        table.insert(cards2,self)

        table.sort(cards2,function(a,b)
            local a1 = table.find(ac.card_class,a['分类1']) or 0
            local a2 = table.find(ac.card_class,a['分类2']) or 0
            local a3 = table.find(ac.card_class,a['分类3']) or 0
            local b1 = table.find(ac.card_class,b['分类1']) or 0
            local b2 = table.find(ac.card_class,b['分类2']) or 0
            local b3 = table.find(ac.card_class,b['分类3']) or 0
            return a1*100 + a2*10 + a3<b1*100 + b2*10 + b3
        end)
        
        player:notify('英雄-吞噬天赋',hero,self)
        player:notify('玩家-刷新UI',player)

    end
end

--升级卡片
function upgrade_card(self,name)
    local hero = self.owner
    local player = hero and hero.owner
    if player then
        --self:remove()
        hide_card(self)

        local temp = hero:add_skill(name,'隐藏')
        local cards1 = hero:get_data('展示天赋表') or {}
        local cards2 = hero:get_data('吞噬天赋表') or {}
        
        player:notify('玩家-刷新UI',player)
    end
    
end

--计数修改
function add_card_count(hero,name,num)
    local name = ('%s-计数'):format(name)
    hero:set_data(name,hero:get_data(name,0) + num)
end

function get_card_list(hero,name)
    local list = {}
    local data = hero:get_data('展示天赋表') or {}
    for i=1,12 do
        local card = data[i]
        if card and (name==nil or card.card_class1[name]) then
            table.insert(list,card)
        end
    end
    return list
end

local tips = {}
ac.game:event '游戏-播放UR介绍'(function(_,str)
    if #tips==0 then
        ac.loop(1000,function(t)
            local tip = table.remove(tips,1)
            if tip then
                ac.player.self:send_msg(('|cffff00ff%s|r'):format(tip))
            else
                t:remove()
            end
        end)
    end
    local strs = split_string(str,'\n')
    for _,stra in ipairs(strs) do
        stra = split_string(stra,'|n')
        for _,str in ipairs(stra) do
            table.insert(tips,str)
        end
    end
end)